package cn.tedu.reflect;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class ClassDemo5 {
    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        //
        Class<String> clz = String.class;

        //获取指定方法
        //返回Method类型的对象---具体方法
        Method m = clz.getDeclaredMethod
                ("charAt", int.class);
        //实例对象
        String str="aegvf";

        //执行方法
        //str.chatAt(1)
        System.out.println(m.invoke(str,1));
    }
}
